package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.excelption.DBException;
import com.baichang.framework.model.Page;
import org.springframework.stereotype.Repository;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.AppVersionDao;
import com.baichang.taoshunda.entity.AppVersion;

import java.util.Map;

@Repository
public class AppVersionDaoImpl extends BaseDaoImpl<AppVersion> implements AppVersionDao {

    /**
     * 查询
     */
    @Override
    public Page<Map<String, Object>> queryAppPage(int id, int nowPage, int pageSize) {
        String sql = "select * from t_app_version ";
        if (id > 0) {
            sql += " where id = ?";
        }
        return pageForMapList(sql, nowPage, pageSize);
    }

    public int update(Map<String, Object> map, int id) {
        return update(" id=? ", map, id);
    }


    /**
     * 进行删除
     *
     * @param id
     * @return
     * @throws DBException
     */

    @Override
    public int delete(int id) throws DBException {
        String sql = " id=" + id + "";
        return delete(sql);
    }

    /**
     * 根据平台获取版本信息
     *
     * @param platform 平台
     * @return
     */
    @Override
    public AppVersion getAppVersionByPlatform(Integer platform) {
        String sql = " SELECT * FROM {table} WHERE dev_platform=? ";
        return queryForBean(sql, platform);
    }
}